Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BASW-131: Membership end date rules #6

Open
wants to merge 3 commits into
base: 7.x-4.x
Choose a base branch
from

Conversation

nishant-bhorodia
Copy link

@nishant-bhorodia nishant-bhorodia commented Nov 27, 2018

Overview:
In Webform/CiviCRM it is not possible

  1. To specify the end date of a new membership.
  2. Calculate pro-rate for membership.

Solution:
This PR adds the functionality to

  1. Specify End date for a membership.
  2. Calculate pro-rate for a membership based on the formula below:

Pro-rated membership fee = (regular membership fee/ number of days in regular membership period) x number of days in pro-rated membership period

'value' => 0,
'exposed_empty_option' => t('Automatic'),
);
$fields['membership_start_date_memberships'] = array (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe membership_start_date_rules_memberships is more clear, same for end_date_rules

'expose_list' => TRUE,
'extra' => array('multiple' => 1),
);
$fields['membership_pro_rate_membership'] = array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this field is not related to the commit, it should not be here, and while it is fine for this PR, I think it is important to not do that when you open the PR against webform_civicrm core repo.

);
$fields['membership_end_date_memberships'] = array (
'name' => t('Select Membership Types'),
'type' => 'select',
'expose_list' => TRUE,
'extra' => array('multiple' => 1),
);
$fields['membership_pro_rate_membership'] = array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you removed this field on purpose ? or is it by mistake ?

@@ -984,6 +984,37 @@ class wf_crm_admin_form {
}
}
}

// Pro rate price checkbox
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be easy to move this logic to a new private method with a clear name ?

/**
* Validate function for membership date rules.
*/
public function validateMembershipDateRules() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this to be public method

* Validate function for membership date rules.
*/
public function validateMembershipDateRules() {
if (!empty($this->data['membership'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or :

if (empty($this->data['membership'])) {
return;
}
// rest of the code

* @param Array $item
* @return Float $price
*/
private function pro_rated_membership_fee($type, $price, $c, $n, $item) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or change the method name to : caculateMembershipProRateFee

* @param Float $price
* @param Integer $c
* @param Array $item
* @return Float $price
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docblock params does not match the method params

* @param Array $item
* @return Float $price
*/
private function pro_rated_membership_fee($type, $price, $c, $n, $item) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you replace $c and $n and $item with names that represent what they actually about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants